Skip to content

[extension.ai.agent] adopt unified awesome-azd templates.json manifest#7921

Merged
hemarina merged 3 commits into
Azure:mainfrom
hemarina:hemarina/agent-init-templates-json
Apr 29, 2026
Merged

[extension.ai.agent] adopt unified awesome-azd templates.json manifest#7921
hemarina merged 3 commits into
Azure:mainfrom
hemarina:hemarina/agent-init-templates-json

Conversation

@hemarina

@hemarina hemarina commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #7920

Summary

Updates azd ai agent init to consume the unified awesome-azd templates.json manifest landed in awesome-azd#841. Agent-init templates are now identified by the templateType: "extension.ai.agent" discriminator within the shared manifest.

Changes

init_from_templates_helpers.go

  • AgentTemplate schema: Languages []string, ExtensionFramework string, TemplateType string (replaces singular Language / Framework).
  • New constant templateTypeExtensionAIAgent = "extension.ai.agent".
  • Split fetcher into fetchAgentTemplates (production) + fetchAgentTemplatesFromURL (URL-injectable, used by tests). Post-unmarshal filter keeps only extension.ai.agent entries.
  • Language prompt: C# value csharpdotnetCsharp (matches awesome-azd languages token).
  • Language match uses slices.Contains(t.Languages, …); label uses t.ExtensionFramework.

init_from_templates_helpers_test.go

  • Updated TestFetchAgentTemplates:
    • success filters by templateType — mixed manifest (agent + gallery + future-extension entries); asserts only agent entries survive and new field names round-trip.
    • Added manifest with only gallery entries returns empty.
    • Existing HTTP error, invalid JSON, empty array cases retained.

Coordination

  • awesome-azd #841 must merge before this lands.
  • ⏳ Reroute https://aka.ms/foundry-agents → awesome-azd templates.json raw URL (owner: @therealjohn) to coincide with this PR''s release.

Test plan

  • go test ./... in cli/azd/extensions/azure.ai.agents — all packages green.
  • go vet ./... clean.
  • Manual smoke test of azd ai agent init once redirect is repointed (post-merge).

Risks

Cutover coordination: until the redirect is repointed, both PRs are dormant. After repoint, older CLI versions (still on the singular-field schema) will start receiving the new mixed array and fail. Recommend a CLI release immediately after redirect change, plus an azd minimum-version note in the awesome-azd PR.

@hemarina hemarina changed the title feat(ai-agents): adopt unified awesome-azd templates.json manifest [extension.ai.agent] adopt unified awesome-azd templates.json manifest Apr 28, 2026
@hemarina
hemarina marked this pull request as ready for review April 28, 2026 02:22
Copilot AI review requested due to automatic review settings April 28, 2026 02:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the azd ai agent init template catalog consumer in the azure.ai.agents extension to read from the unified awesome-azd templates.json manifest and select only entries marked as agent-init templates via templateType: "extension.ai.agent".

Changes:

  • Updates the AgentTemplate schema to match the unified manifest (languages[], extensionFramework, templateType), and filters fetched entries by templateType.
  • Splits template fetching into a production wrapper + URL-injectable helper for tests.
  • Updates language token for C# to dotnetCsharp and matches templates via slices.Contains across multi-language entries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_templates_helpers.go Aligns template model to unified manifest, filters by templateType, updates language selection/matching and label framework field.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_templates_helpers_test.go Updates fetch tests to validate templateType filtering and new schema fields; adds a gallery-only manifest case.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_templates_helpers.go Outdated

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean change. The fetch refactor (URL-injectable + post-unmarshal filter) is straightforward, filtering logic handles edge cases correctly (slices.Contains on nil is safe), and test coverage for the new filtering behavior is solid.

One optional nit: the Tags field name could be ExtensionTags to match ExtensionFramework naming - but since the field isn't referenced anywhere in the extension today, it's purely cosmetic. Up to you.

The coordinated cutover plan (redirect repoint + immediate CLI release) addresses the backward compat risk well.

@trangevi trangevi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've asked @therealjohn to take a look at this and make sure it's holding to what we've currently got

@therealjohn therealjohn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Needs to be paired with a merge of Azure/awesome-azd#841 and update the aka.ms link to point to the unified template.json

@wbreza wbreza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review: PR #7921

TL;DR

Updates �zd ai agent init to consume the unified awesome-azd emplates.json manifest. Clean function split for testability, good filtering logic, modern Go idioms throughout. A few hardening suggestions below — nothing blocking.

🟡 Medium (3 findings)

1. Consider a more descriptive error when filtering eliminates all templates
etchAgentTemplatesFromURL filters by emplateType == "extension.ai.agent". If the manifest has entries but none match, the downstream "no agent templates available" error doesn't reveal the filter mismatch — worth including the count fetched vs. matched for transition-period debugging.

2. Missing response body size limit
io.ReadAll(resp.Body) has no size cap. While the URL is a hardcoded �ka.ms endpoint, adding io.LimitReader(resp.Body, 1010241024) is defensive best practice.

3. No debug logging when templates are filtered out
During the awesome-azd#841 transition, silent filtering makes it hard to diagnose "templates disappeared" issues. A debug log after filtering (e.g., "fetched %d entries, %d matched templateType") would help.

🟢 Low (4 findings)

4. Language filter missing pre-allocation — �ar filtered []AgentTemplate in promptAgentTemplate doesn't pre-allocate, unlike the templateType filter. Minor consistency fix: make([]AgentTemplate, 0, len(templates)).

5. Gosec nolint comment could reference specific rule — e.g., //nolint:gosec // G107: URL is the hardcoded agentTemplatesURL constant or a local httptest server.

6. Test: assert TemplateType on second result
esult[1].TemplateType isn't asserted. Minor gap alongside the existing
esult[0] assertion.

7. Test: empty Languages edge case — No test for templates with languages: []. Behavior is correct (slices.Contains returns false), but documenting it in tests would strengthen coverage.

✅ What Looks Good

  • Clean etchAgentTemplates → etchAgentTemplatesFromURL split eliminates test helper duplication
  • Modern Go: slices.Contains, .Context(), pre-allocated filtering
  • Good mixed-manifest test coverage (gallery + agent + future extension types)
  • Solid error wrapping with %w throughout
Priority Count
Critical 0
High 0
Medium 3
Low 4
Total 7

@hemarina
hemarina enabled auto-merge (squash) April 28, 2026 22:13

@JeffreyCA JeffreyCA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Needs to be paired with a merge of Azure/awesome-azd#841 and update the aka.ms link to point to the unified template.json

@therealjohn / @trangevi How concerned are we about the aka.ms link change breaking older extension versions? Users on older versions may see this error when trying to browse the templates:

image

A safer approach might be to keep the existing aka.ms link pointing to the same file, then use a new aka.ms link or use https://azure.github.io/awesome-azd/templates.json

@hemarina
hemarina disabled auto-merge April 28, 2026 23:40
@hemarina

Copy link
Copy Markdown
Contributor Author

Great! Needs to be paired with a merge of Azure/awesome-azd#841 and update the aka.ms link to point to the unified template.json

@therealjohn / @trangevi How concerned are we about the aka.ms link change breaking older extension versions? Users on older versions may see this error when trying to browse the templates:

image A safer approach might be to keep the existing aka.ms link pointing to the same file, then use a new aka.ms link or use https://azure.github.io/awesome-azd/templates.json

How about updating the link to https://azure.github.io/awesome-azd/templates.json. Then after updating the aka.ms link, open a PR to change back to aka.ms?

@JeffreyCA

Copy link
Copy Markdown
Contributor

Great! Needs to be paired with a merge of Azure/awesome-azd#841 and update the aka.ms link to point to the unified template.json

@therealjohn / @trangevi How concerned are we about the aka.ms link change breaking older extension versions? Users on older versions may see this error when trying to browse the templates:
image
A safer approach might be to keep the existing aka.ms link pointing to the same file, then use a new aka.ms link or use https://azure.github.io/awesome-azd/templates.json

How about updating the link to azure.github.io/awesome-azd/templates.json. Then after updating the aka.ms link, open a PR to change back to aka.ms?

Yes that would work

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean migration to the shared awesome-azd manifest. The filtering logic is straightforward, slices.Contains on Languages handles nil safely, and the error-on-empty-filter is a solid guard for the transition period. Test coverage with mixed manifests validates the discriminator filtering well.

One tiny nit (non-blocking): the log.Printf format says 'fetched %d' but that's the filtered count - 'matched %d' might read slightly clearer. Not worth a change.

@hemarina
hemarina merged commit 693406b into Azure:main Apr 29, 2026
19 checks passed
Copilot AI pushed a commit that referenced this pull request May 21, 2026
#7921)

* fix 7920

* address feedback
Co-authored-by: therealjohn <1501196+therealjohn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd ai agent init: update template fetcher for unified awesome-azd templates.json

7 participants